package com.cortex.pineapple.database;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.cortex.pineapple.adapters.Header;
import com.cortex.pineapple.adapters.ItemList;
import com.cortex.pineapple.adapters.Item;
import com.cortex.pineapple.adapters.ItemList.ITEM_TYPE;
import com.cortext.pineapple.link.Link;

public class SeasonQuerySearch implements Season,Header{

	// for data base
	private long id;
	// season name
	private String name;
	// the query of user
	private String query;
	// all links the user entered
	private List<VisitLink> visitLinks;
	// start season
	private Date startSeason;
	
	public SeasonQuerySearch(){
		// default constructor
	}
	
	public SeasonQuerySearch(String name, String query, List<VisitLink> links,
			Date startSeason) {
		this.name = name;
		this.query = query;
		this.visitLinks = links;
		this.startSeason = startSeason;
	}
	public SeasonQuerySearch(long id, String name, String query, List<VisitLink> links,
			Date startSeason) {
		this.id = id;
		this.name = name;
		this.query = query;
		this.visitLinks = links;
		this.startSeason = startSeason;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getQuery() {
		return query;
	}
	public void setQuery(String query) {
		this.query = query;
	}
	public List<VisitLink> getVisitLinks() {
		if(visitLinks == null){
			visitLinks = new ArrayList<VisitLink>();
		}
		return visitLinks;
	}
	public void setVisitLinks(List<VisitLink> links) {
		this.visitLinks = links;
	}
	public Date getStartSeason() {
		return startSeason;
	}
	public void setStartSeason(Date startSeason) {
		this.startSeason = startSeason;
	}
	@Override
	public void addVisitLink(VisitLink visitLink) {
		visitLinks.add(visitLink);
	}
	@Override
	public String toString() {
		StringBuilder links = new StringBuilder();
		links.append("\n");
		for (VisitLink visitLink : visitLinks) {
			links.append(visitLink);
		}
		links.append("\n");
		StringBuilder str = new StringBuilder();
		str.append("SeasonQuerySearch [id=" + id + ", name=" + name + ", query="
				+ query + ", visitLinks=");
		for (VisitLink visitLink : visitLinks) {
			str.append(visitLink.toString());
		}
		str.append(", startSeason="
				+ startSeason + ", endSeason=" + "]");
		return str.toString();
	}

	@Override
	public boolean isHeader() {
		return true;
	}

	@Override
	public Object getData() {
		return this;
	}

	@Override
	public Date getDate() {
		return startSeason;
	}

	@Override
	public List<Item> getItems() {
		List<Item> list = new ArrayList<Item>();
		list.addAll(visitLinks);
		return list;
	}
	@Override
	public ITEM_TYPE getType() {
		return ITEM_TYPE.HEADER;
	}

	
}
